﻿<UserControl
	x:Class="Week02Samples.ContentStream.View"
	x:Name="root"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:dxc="clr-namespace:SharpDX.WPF;assembly=SharpDX.WPF"
	xmlns:local="clr-namespace:Week02Samples.ContentStream"
	>
	<UserControl.Resources>

		<local:Renderer x:Key="scene"/>
		<local:EnumConverter x:Key="cvt"/>

	</UserControl.Resources>
	<Grid>
		
		<!-- scene rendering -->
		<dxc:DXElement x:Name="dxview" Renderer="{StaticResource scene}"/>
		
		<!-- render info -->
		<TextBlock 
			Text="{Binding DisplayInfo, Source={StaticResource scene}}"
			HorizontalAlignment="Left" VerticalAlignment="Top"
			Foreground="Yellow" FontWeight="Bold"/>
			
		<!-- settings control -->
		<StackPanel Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="Bottom" MaxWidth="200">

			<TextBlock 
				Margin="5"
				HorizontalAlignment="Left"
				Text="{Binding ViewHeight, StringFormat='{}View Height: {0:0.00}', Source={StaticResource scene}}"/>

			<Slider 
				Margin="5"
				Maximum="100" 
				Value="{Binding ViewHeight, Source={StaticResource scene}, Mode=TwoWay}"
				/>

			<TextBlock 
				Margin="5"
				HorizontalAlignment="Left"
				Text="{Binding VisibleRadius, StringFormat='{}Visible Radius: {0:0.00}', Source={StaticResource scene}}"/>

			<Slider 
				Margin="5"
				Minimum="0"
				Maximum="{Binding LoadingRadius, Source={StaticResource scene}}" 
				Value="{Binding VisibleRadius, Source={StaticResource scene}, Mode=TwoWay}"
				/>

			<TextBlock 
				HorizontalAlignment="Left"
				Text="{Binding NumResourceToLoadPerFrame, StringFormat='{}Create up to {0} items per frame', Source={StaticResource scene}}"/>

			<Slider 
				Margin="5"
				Maximum="30" 
				Value="{Binding NumResourceToLoadPerFrame, Source={StaticResource scene}, Mode=TwoWay}"
				/>

			<TextBlock 
				Margin="5"
				HorizontalAlignment="Left"
				Text="{Binding UploadToVRamEveryNthFrame, StringFormat='{}Upload to VRam every {0} frames', Source={StaticResource scene}}"/>

			<Slider 
				Margin="5"
				Minimum="1"
				Maximum="10" 
				Value="{Binding UploadToVRamEveryNthFrame, Source={StaticResource scene}, Mode=TwoWay}"
				/>

			<CheckBox Margin="5" IsChecked="{Binding Wireframe, Source={StaticResource scene}, Mode=TwoWay}" Content="Wireframe"/>
			
			<Button Margin="5" Click="DoStartOver">Start Over</Button>
		
		</StackPanel>

		<!-- Init screen -->
		<Grid 
			Background="LightSteelBlue" 
			Visibility="{Binding AppState, Source={StaticResource scene}, Converter={StaticResource cvt}}">
			<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">

				<TextBlock Text="How would you like to load the scene?" 
					   FontWeight="Bold"
					   FontSize="18"
					   Margin="5"/>

				<ListBox
					ItemsSource="{Binding LoadTypes, ElementName=root}"
					SelectedItem="{Binding LoadType, Source={StaticResource scene}, Mode=TwoWay}"
					Background="{x:Null}"
					BorderThickness="0"
					>
					<ItemsControl.ItemTemplate>
						<DataTemplate>
							<RadioButton 
								Focusable="False" 
								IsHitTestVisible="False" 
								IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}, Mode=TwoWay}" >
								<TextBlock Text="{Binding Converter={StaticResource cvt}}"/>
							</RadioButton>
						</DataTemplate>
					</ItemsControl.ItemTemplate>
				</ListBox>

				<Button Margin="5" Click="DoRun">Run</Button>

				<Button Margin="5" Click="DoDeletePackfile">Delete Packfile</Button>


			</StackPanel>
		</Grid>


	</Grid>
</UserControl>
